def is_valid_sequense(sequense):
    stack = []
    brackets = {'(': ')', '[':']', '{' : '}', '<' : '>'}
    for char in sequense:
        if char in brackets.keys():
            stack.append(char)
        elif char in brackets.values():
            if not stack or brackets[stack.pop()] != char:
                return False

    return not stack

sequense = input("Введите скобочную последовательность: ")
if is_valid_sequense(sequense):
    print("True")
else:
    print("False")
